import * as crypto from "crypto"

/**
 * Calculate the hash value of a string
 * @param data
 */
export function calculateHash(data: string): string {
  const hash = crypto.createHash("sha256")
  hash.update(data)
  return hash.digest("hex")
}

/**
 * Signing data using a private key
 * @param data
 * @param privateKey
 */
export function signData(data: string, privateKey: string): string {
  const signature = crypto.createSign("sha256")
  signature.update(data)
  return signature.sign(privateKey, "base64")
}
